package org.example.petadoption.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.example.petadoption.entity.DashboardDTO;
import org.example.petadoption.entity.Merchant;

/**
 * <p>
 * 商家信息表 Mapper 接口
 * </p>
 *
 * @author PetAdoption
 * @since 2025-10-20
 */
public interface MerchantMapper extends BaseMapper<Merchant> {

    @Select("""
        SELECT 
            IFNULL(SUM(o.total_amount), 0) AS totalSales,
            COUNT(o.id) AS orderCount,
            (SELECT COUNT(*) FROM merchant) AS merchantCount,
            (SELECT COUNT(*) FROM user) AS userCount
        FROM orders o
    """)
    DashboardDTO getDashboardStats();

}
